<template>
  <svg :class="svgClass" aria-hidden="true" :font-size="props.size">
    <use :xlink:href="iconName" />
  </svg>
</template>
<script lang="ts" setup>
import { computed, defineProps } from "vue";
const props = defineProps({
  name: { // svg文件名称
    type: String,
    required: true
  },
  iconClass: { // svg 类名
    type: String,
    required: false,
    default: ''
  },
  size: {
    type: String,
    required: false,
    default: '1em'
  }
})

const iconName = computed(() => {
  return props.name ? `#icon-${props.name}` : "#icon";
})
const svgClass = computed(() => {
  return props.iconClass ? "svg-icon " + props.iconClass : "svg-icon";
})

</script>

<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  vertical-align: middle;
  fill: currentColor;
  overflow: hidden;
}
</style>
